/**
 * 
 */
package com.myworld;

import org.junit.Before;
import org.junit.Test;

import cn.myworld.orm.core.ORMConfig;
import cn.myworld.orm.core.ORMSession;
import cn.myworld.orm.test.entity.Book;

public class BookDao {
    private ORMConfig config;

    @Before
    public void init() {
        config = new ORMConfig();
    }

    @Test
    public void testSave() throws Exception {
        ORMSession session = config.buildORMSession();
        Book book = new Book();
        book.setId(1);
        book.setName("降龙十八掌");
        book.setAuthor("不知道");
        book.setPrice(9.9);
        session.save(book);
        session.close();
    }

    @Test
    public void testDelete() throws Exception {
        ORMSession session = config.buildORMSession();
        Book book = new Book();
        book.setId(1);
        session.delete(book);
        session.close();
    }

    @Test
    public void testFindOne() throws Exception {
        ORMSession session = config.buildORMSession();
        Book book = (Book) session.findOne(Book.class, 2);
        System.out.println(book);
        session.close();
    }

}
